//
//  StudyFourTableViewCell.m
//  TeacherNet
//
//  Created by slz on 2017/12/18.
//  Copyright © 2017年 bnsr. All rights reserved.
//

#import "StudyFourTableViewCell.h"

@implementation StudyFourTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        NSInteger leftRightMargin = 15;
        CGFloat maxCourseLabelWidth = (kScreenWidth - 40) * .5;
        
        _mianNameLabel = [UILabel new];
        _mianNameLabel.textColor = kDark_TextColor_Default;
        _mianNameLabel.fontSize = kFont_Size_Middle_Title;
        [self.contentView addSubview:_mianNameLabel];
        [_mianNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.mas_equalTo(leftRightMargin);
            make.trailing.mas_equalTo(-leftRightMargin);
            make.top.mas_equalTo(20);
        }];
        
        _courseLabel = [UILabel new];
        _courseLabel.textColor = kLoginGreenColor;
        _courseLabel.fontSize = kFont_Size_Cotent_Middle;
        [self.contentView addSubview:_courseLabel];
        [_courseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(leftRightMargin);
            make.top.mas_equalTo(_mianNameLabel.mas_bottom).offset(15);
            make.width.mas_equalTo(maxCourseLabelWidth);
        }];
        
        _redLabel = [UILabel new];
        _redLabel.textColor = [UIColor redColor];
        _redLabel.fontSize = kFont_Size_Cotent_Middle;
        [self.contentView addSubview:_redLabel];
        [_redLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView.mas_right).offset(-leftRightMargin);
            make.top.mas_equalTo(_courseLabel.mas_top);
        }];
        
        _rightLabel = [UILabel new];
        _rightLabel.textColor = kLight_TextColor_Default;
        _rightLabel.fontSize = kFont_Size_Cotent_Middle;
        [self.contentView addSubview:_rightLabel];
        [_rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(_redLabel.mas_left);
            make.top.mas_equalTo(_courseLabel.mas_top);
        }];
        
        _timeLabel = [UILabel new];
        _timeLabel.textColor = kLight_TextColor_Default;
        _timeLabel.fontSize = kFont_Size_Cotent_Middle;
        [self.contentView addSubview:_timeLabel];
        [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(_rightLabel.mas_left).offset(-10);
            make.top.mas_equalTo(_courseLabel.mas_top);
        }];
        
        UIView * lineView = [UIView quickLineColorView];
        [self.contentView addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.and.bottom.mas_equalTo(self.contentView);
            make.height.mas_equalTo(.5);
        }];
    }
    return  self;
}


- (void)layoutWithState:(StudyPageType)pageType andModel:(StudyHomeWorkOrExamModel *)model
{
    _mianNameLabel.text = model.courseName;
    _courseLabel.text = model.title;
    _timeLabel.text = model.time;
    
    switch (pageType) {
        case StudyPageTopicTypeHomeWork:
            _rightLabel.text = @"成绩:";
            _redLabel.text = model.scoreState;
            _redLabel.textColor = kLight_TextColor_Default;
            break;
        case StudyPageTopicTypeExam:
            _rightLabel.text = @"得分:";
            _redLabel.text = [NSString stringWithFormat:@"%.1f",model.scoreFloat];
            _redLabel.textColor = [UIColor redColor];
            break;
        case StudyPageTopicTypeNote:
            _courseLabel.text = [NSString stringWithFormat:@"%@>%@",model.title,model.hourTitle];
            _rightLabel.text = @"";
            _redLabel.text = @"";
            break;
        case StudyPageTopicTypeTopic:
            _rightLabel.text = @"浏览:";
            _redLabel.text = model.watchTime;
            _redLabel.textColor = [UIColor redColor];
            break;
        default:

            break;
    }
    
    

}




@end
